/**
 * 成品入库管理API接口
 * 包含成品入库单的查询、创建、更新、执行等相关接口
 */

import { http } from "@/common/service/service.js";

// 成品入库单相关接口
const finishedGoodsInbound = {
  // 获取成品入库单列表
  getFinishedGoodsInboundList(params) {
    return http.get("/wms/finished-goods-inbound/list", { params });
  },

  // 获取成品入库单详情
  getInboundDetail(id) {
    return http.get(`/wms/finished-goods-inbound/detail/${id}`);
  },

  // 创建成品入库单
  createInbound(data) {
    return http.post("/wms/finished-goods-inbound/add", data);
  },

  // 更新成品入库单
  updateInbound(data) {
    return http.put("/wms/finished-goods-inbound/edit", data);
  },

  // 删除成品入库单
  deleteInbound(id) {
    return http.delete(`/wms/finished-goods-inbound/delete`, { id });
  },

  // 批量删除成品入库单
  deleteBatch(ids) {
    return http.delete("/wms/finished-goods-inbound/deleteBatch", {
      ids: ids.join(","),
    });
  },

  // 执行入库
  executeInbound(data) {
    return http.post("/wms/finished-goods-inbound/execute", data);
  },

  // 分批次执行入库
  executeBatchInbound(data) {
    return http.post("/wms/finished-goods-inbound/executeBatch", data);
  },

  // 获取仓库列表
  getWarehouseList(params) {
    return http.get("/wms/warehouse/listAll", { params });
  },

  // 获取库位列表
  getLocationList(warehouseId) {
    return http.get(`/wms/location/queryByWarehouseId`, {
      params: { warehouseId },
    });
  },

  // 通过订单创建入库单
  createInboundByOrder(data) {
    return http.post("/wms/finished-goods-inbound/createByOrder", data);
  },

  // 导出入库单
  exportInbound(params = {}) {
    return http.get("/wms/finished-goods-inbound/exportXls", params);
  },

  // 导入入库单
  importInbound(params = {}) {
    return http.post("/wms/finished-goods-inbound/importExcel", params);
  },
};

// 导出所有接口方法
export const {
  getFinishedGoodsInboundList,
  getInboundDetail,
  createInbound,
  updateInbound,
  deleteInbound,
  deleteBatch,
  executeInbound,
  executeBatchInbound,
  createInboundByOrder,
  exportInbound,
  importInbound,
  getWarehouseList,
  getLocationList,
} = finishedGoodsInbound;

// 默认导出整个对象
export default finishedGoodsInbound;
